package com.itheima.stock.job;

import com.itheima.stock.service.StockTimerTaskService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class stockJob {
    private static Logger logger = LoggerFactory.getLogger(stockJob.class);
    @Resource
    private StockTimerTaskService stockTimerTaskService;

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("demoJobHandler")
    public void demoJobHandler() throws Exception {
        //todo 打印时间
        System.out.println("当前时间点" + DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
    }
    /**
     * 定时采集A股大盘数据
     * 建议：针对不同的股票数据，定义不同的采集任务，解耦
     */
    @XxlJob("getInnerMarketInfo")
    public void getStockInfos(){
        stockTimerTaskService.getInnerMarketInfo();
    }
    /**
     * 采集个股数据
     */
    @XxlJob("getStockRtIndex")
    public void getStockRtIndex(){
        stockTimerTaskService.getStockRtIndex();
    }
}